< previous page page_623 next page >

Page 623
are caused by light reaching the pixel from some other part of the scene. This includes light that reaches the point after reflecting off other objects and light that reaches the point by passing through a transparent surface. The following sections explain how to add the local and global terms you need to handle reflective and transparent objects.
Reflected Light
To compute the color of a pixel, calculate the local components directly. Then add in the global components. Because you know the viewing direction and the surface normal, you can calculate the direction from which reflected light would need to come if it were to hit the surface and reflect toward the viewpoint.
In Figure 17.20, V is the vector from the surface to the viewpoint, and N is the surface's normal vector at that point.
Using these two vectors V and N, you can calculate M, the reflection vector for the vector V. The calculation is similar to the calculation in Chapter 16, Shading Models, of the vector R that gives the direction of specular reflection. When those results are applied to this situation, the vector M is given by the equation:
e10a6a0a59f035e870d90cca05b85fce.gif
M = 2 * N * (V  N) - V
For example, the X component of the vector M is:
e10a6a0a59f035e870d90cca05b85fce.gif
Mx = 2 * Nx * (N  V) - Vx
Once you have found the vector M, you need to follow that vector until you intersect another object. The color at that point of intersection determines the color that reflects off the original object to the viewpoint.
At this point you can start to see the recursive nature of the algorithm. You begin with a ray starting at the original point of intersection. You need to trace this ray to find the color of the point where it intersects another object. This process is identical to that in the original problem in which you needed to follow a ray starting at the viewpoint to find the color of the point where that ray intersects an object.
z0643-01.gif
Figure 17.20
The vector M points in the direction of reflection.

 
< previous page page_623 next page >